<?php

namespace App\Containers\AppSection\Moderation\UI\API\Requests;

use App\Ship\Parents\Requests\Request;
use Illuminate\Validation\Rule;

class GetModeratorModerationsRequest extends Request
{

    /**
     * Define which Roles and/or Permissions has access to this request.
     */
    protected array $access = [
        'permissions' => '',
        'roles' => 'moderator|admin',
    ];

    /**
     * Id's that needs decoding before applying the validation rules.
     */
    protected array $decode = [
        // 'id',
    ];

    /**
     * Defining the URL parameters (e.g, `/user/{id}`) allows applying
     * validation rules on them and allows accessing them like request data.
     */
    protected array $urlParameters = [
        // 'id',
    ];

    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        return [
            'status' => ['required', Rule::in(['projects_checking', 'projects_returned'])],
            'from' => ['nullable', 'date_format:d.m.Y'],
            'to' => ['nullable', 'date_format:d.m.Y'],
            'from_min' => ['nullable', 'numeric'],
            'to_min' => ['nullable', 'numeric'],
            'from_target' => ['nullable', 'numeric'],
            'to_target' => ['nullable', 'numeric'],
            'from_project' => ['nullable', 'date_format:d.m.Y'],
            'to_project' => ['nullable', 'date_format:d.m.Y'],
            'from_returned' => ['nullable', 'numeric'],
            'to_returned' => ['nullable', 'numeric'],
            'pledge' => ['nullable', Rule::in([1, 2])],
            'type' => ['nullable', Rule::in([1, 2])]
        ];
    }

    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return $this->check([
            'hasAccess'
        ]);
    }
}
